using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Pokemon
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class PokemonGame : Game
    {
        readonly GraphicsDeviceManager _graphics;
        private readonly ScreenManager _screenManager;      

        public PokemonGame()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
             
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromSeconds(1/60.0);

            _graphics.IsFullScreen = true;

            // Extend battery life under lock.
            InactiveSleepTime = TimeSpan.FromSeconds(1);

            _screenManager = new ScreenManager(this);
            Services.AddService((typeof(ScreenManager)), _screenManager);
            Components.Add(_screenManager);

            BackgroundScreen backgroundScreen = new BackgroundScreen(this);
            MainMenuScreen mainMenuScreen = new MainMenuScreen(this);
            GameplayScreen gameplayScreen = new GameplayScreen(this);
            backgroundScreen.Add(mainMenuScreen);

            _screenManager.AddScreen(mainMenuScreen, @"mainMenu");
            _screenManager.AddScreen(backgroundScreen, @"background");
            _screenManager.AddScreen(gameplayScreen, "game" + "play");  
    
            _screenManager.SwitchScreen("background");            
        }

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                Exit();
            base.Update(gameTime);
        }
    }
}
